<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 函数对象
      function makeSum() {
        sum.r = 0;
        function sum(n) {
          sum.r += n;
          return sum;
        }
        sum.toString = function () {
          return this.r;
        };
        return sum;
      }

      const sum1 = makeSum();
      console.log(sum1(1)(2)(3) - 100);

      const sum2 = makeSum();
      console.log(sum2(1)(2)(8) + Number("100"));
    </script>
  </body>
</html>
